#include <stdio.h>

int main(int argc, char* argv[]){
	FILE *f;
	int i = 0, j, total_char = 0, total_line = 0;
	int total_word = 0;
	char c;

	if (argc <  2){
		printf("Usage: %s <file 1> <file 2> <file n>\n", argv[0]);
		return (1);
	}
	for (j = 1; j < argc; j++){
		if ((f = fopen(argv[j], "r")) == NULL){
			printf ("Error while opening the file %s\n", argv[j]);
			return (2);
		} else {
			while ((c = fgetc(f)) != EOF){
				if (c == ' '){
					total_char--;
					total_word++;
				}
				if (c == '\n'){
					total_char--;
					total_line++;
					total_word++;
				}
				total_char++;
			}
		printf ("The file %s has %d lines\n", argv[j], total_line);
		printf ("The file %s has %d words\n", argv[j], total_word);
		total_word = 0;
		total_line = 0;
		fclose(f);
		}
	}
	total_char = total_char + i;
	printf ("j = %d\n", j);
	printf ("The file total of characters is %d characters\n", total_char);
	i = 0;
	return (0);
}
